幫助中心
香港服務(wù)器租用幫助
香港服務(wù)器Ubuntu配置單個IP與整段IP教程
2022-09-30 22:50:38

Ubuntu是私有標(biāo)準桌面化Linux系統(tǒng),是大家在租用香港服務(wù)器時使用的操作系統(tǒng)之一。近日有網(wǎng)友咨詢香港服務(wù)器Ubuntu如何配置單個IP與整段IP,本文就為大家介紹下操作步驟,僅供大家參考。


一、多IP不同段配置方法:

多個不同IP段的 /etc/network/interfaces 配置文件的范例如下:

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

auto eth0

iface eth0 inet static

address 8.8.8.2

netmask 255.255.255.248

gateway 8.8.8.1 (如果是多個不同IP段,只要1個gateway配置就行,其它IP不需要配置gateway)

auto eth0:0

iface eth0:0 inet static

address 8.8.8.3

netmask 255.255.255.248

auto eth0:1

iface eth0:1 inet static

address 8.8.8.4

netmask 255.255.255.248

auto eth0:2

iface eth0:2 inet static

address 8.8.8.5

netmask 255.255.255.248

auto eth0:3

iface eth0:3 inet static

address 8.8.8.6

netmask 255.255.255.248

auto eth0:4

iface eth0:4 inet static

address 6.6.6.130(雖然這是不同的IP段,但不需要配置gateway,只需配置netmask即可)

netmask 255.255.255.224

auto eth0:5

iface eth0:5 inet static

address 6.6.6.131

netmask 255.255.255.224

如果想添加更多獨立IP的話,按照上述方法進行添加就行了。

配置文件完成后,用命令/etc/init.d/networking restart 重啟網(wǎng)絡(luò),不需要reboot重啟服器。/etc/init.d/networking restart重啟網(wǎng)絡(luò)的時候,如果你的配置文件有錯誤,一般都有提示的。

二、整段IP添加方法

整段IP添加使用腳本添加,具體如下:

# !/bin/bash

for ((i=10;i<=255;i=i+1))

do

echo “auto eth0:$i”>>/etc/network/interfaces

echo “iface eth0:$i inet static”>>/etc/network/interfaces

# let j=$i

echo “address 193.10.10.$j”>>/etc/network/interfaces

echo “netmask 255.255.255.0”>>/etc/network/interfaces

echo “gateway 193.10.10.254″>>/etc/network/interfaces


新客優(yōu)惠
特價 酷睿i3系列
性價比熱銷推薦,年銷量第一
1180/月起
USA-IDC為您提供免備案服務(wù)器 0元試用
立即聯(lián)系在線客服,即可申請免費產(chǎn)品試用服務(wù)
立即申請